package com.ruoyi.testDeal.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testDeal.domain.basic.ReportTestinfo;
import com.ruoyi.testDeal.service.IReportTestinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 检测检验报告信息Controller
 * 
 * @author ruoyi
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/testDeal/testinfo")
public class ReportTestinfoController extends BaseController
{
    @Autowired
    private IReportTestinfoService reportTestinfoService;

    /**
     * 查询检测检验报告信息列表
     */
    @PreAuthorize("@ss.hasPermi('testDeal:testinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportTestinfo reportTestinfo)
    {
        startPage();
        List<ReportTestinfo> list = reportTestinfoService.selectReportTestinfoList(reportTestinfo);
        return getDataTable(list);
    }

    /**
     * 导出检测检验报告信息列表
     */
    @PreAuthorize("@ss.hasPermi('testDeal:testinfo:export')")
    @Log(title = "检测检验报告信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReportTestinfo reportTestinfo)
    {
        List<ReportTestinfo> list = reportTestinfoService.selectReportTestinfoList(reportTestinfo);
        ExcelUtil<ReportTestinfo> util = new ExcelUtil<ReportTestinfo>(ReportTestinfo.class);
        util.exportExcel(response, list, "检测检验报告信息数据");
    }

    /**
     * 获取检测检验报告信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:testinfo:query')")
    @GetMapping(value = "/{reportTestId}")
    public AjaxResult getInfo(@PathVariable("reportTestId") Long reportTestId)
    {
        return success(reportTestinfoService.selectReportTestinfoByReportTestId(reportTestId));
    }

    /**
     * 新增检测检验报告信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:testinfo:add')")
    @Log(title = "检测检验报告信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportTestinfo reportTestinfo)
    {
        return toAjax(reportTestinfoService.insertReportTestinfo(reportTestinfo));
    }

    /**
     * 修改检测检验报告信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:testinfo:edit')")
    @Log(title = "检测检验报告信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportTestinfo reportTestinfo)
    {
        return toAjax(reportTestinfoService.updateReportTestinfo(reportTestinfo));
    }

    /**
     * 删除检测检验报告信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:testinfo:remove')")
    @Log(title = "检测检验报告信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportTestIds}")
    public AjaxResult remove(@PathVariable Long[] reportTestIds)
    {
        return toAjax(reportTestinfoService.deleteReportTestinfoByReportTestIds(reportTestIds));
    }
}
